<Project Sdk="Microsoft.Build.NoTargets">

  <!-- installer.tasks needs to be built in advance. -->
  <UsingTask TaskName="RegenerateDownloadTable" AssemblyFile="$(InstallerTasksAssemblyPath)" />

  <Target Name="RegenerateDownloadTable"
          AfterTargets="Build">
    <!--
      Column and row configuration for the readme table. The abbreviations match up with
      reference-style Markdown links in the readme file to figure out what to put in the cells.
    -->
    <PropertyGroup>
      <TablePath>$([MSBuild]::NormalizePath('$(RepoRoot)', 'docs', 'project', 'dogfooding.md'))</TablePath>
    </PropertyGroup>

    <ItemGroup>
      <Branch Include="Main" Abbr="8.0.X" />

      <Platform Include="Windows (x64)" Abbr="win-x64" />
      <Platform Include="Windows (x86)" Abbr="win-x86" />
      <Platform Include="Windows (arm64)" Abbr="win-arm64" />
      <Platform Include="macOS (x64)" Abbr="osx-x64" />
      <Platform Include="macOS (arm64)" Abbr="osx-arm64" />
      <Platform Include="Linux (x64)" Parenthetical=" (for glibc based OS)" Abbr="linux-x64" />
      <Platform Include="Linux (armhf)" Parenthetical=" (for glibc based OS)" Abbr="linux-arm"/>
      <Platform Include="Linux (arm64)" Parenthetical=" (for glibc based OS)" Abbr="linux-arm64" />
      <Platform Include="Linux-musl (x64)" Abbr="linux-musl-x64" />
      <Platform Include="Linux-musl (arm)" Abbr="linux-musl-arm" />
      <Platform Include="Linux-musl (arm64)" Abbr="linux-musl-arm64" />
      <Platform Include="Dpkg Based Systems (x64)" Abbr="deb" />
      <Platform Include="CentOS 7 (x64)" Abbr="centos-7" />
      <Platform Include="RHEL 7.2 (x64)" Abbr="rhel7" />
      <Platform Include="Fedora 27 (x64)" Abbr="fedora-27" />
      <Platform Include="SLES 12 (x64)" Abbr="sles-12" />
      <Platform Include="OpenSUSE 42 (x64)" Abbr="OpenSUSE-42" />
    </ItemGroup>

    <RegenerateDownloadTable ReadmeFile="$(TablePath)"
                             Branches="@(Branch)"
                             Platforms="@(Platform)" />

    <Message Text="$(MSBuildProjectName) -> $(TablePath)" Importance="High" />
  </Target>
</Project>
